<template>
	<view class="question-page">
		<view class="contentBox">
			<view class="content-box">
				<view class="title">请填写举报原因</view>
				<view style="flex: 1;">
					<view class="reason-list">
						<view v-for="(value, key) in reason" :key="key" class="reason-item"
							:class="type === key ? 'active' : ''" @click="type = key">
							{{value}}
						</view>
					</view>
				</view>
			</view>
			<view class="content-box">
				<view class="title">说明</view>
				<view style="flex: 1;">
					<u-textarea v-model="content" placeholder="请简明扼要的阐述您的理由，以便工作人员更好的核实" :clearable="true" border="none"
						:maxlength="200" confirmType="done"></u-textarea>
				</view>
			</view>
			<view class="content-box">
				<view class="title">联系方式(保密)</view>
				<view style="flex: 1;">
					<view class="input-item">
						<view class="item-left">姓名</view>
						<view class="item-right">
							<u-input v-model="report_name" placeholder="您的姓名,方便后续联系" :clearable="true" border="none"
								:customStyle="{height:'88rpx',padding:'0 20rpx'}"></u-input>
						</view>
					</view>
					<view class="input-item">
						<view class="item-left">手机号</view>
						<view class="item-right">
							<u-input v-model="report_mobile" placeholder="请填写手机号" :clearable="true" border="none"
								:customStyle="{height:'88rpx',padding:'0 20rpx'}"></u-input>
						</view>
					</view>
				</view>
			</view>

			<view class="button-group">
				<view class="button1" @click="$u.throttle(submitInfo,2000)">提交</view>
			</view>
		</view>
		<view style="height: 20rpx;"></view>
	</view>
</template>

<script>
	import {
		submitReport,
		getReportOptions
	} from "@/api/gent.js";
	export default {
		data() {
			return {
				type: '',
				content: '',
				report_name: '',
				report_mobile: '',
				pub_id: null,
				reason: [],
			}
		},
		onLoad(options) {
			if (options) {
				this.pub_id = options.pub_id
			}
			this.getReportOptions()
		},
		methods: {
			getReportOptions() {
				getReportOptions().then(res => {
					this.reason = res.data.data
				})
			},
			submitInfo() {
				submitReport({
					type: this.type,
					content: this.content,
					report_name: this.report_name,
					report_mobile: this.report_mobile,
					comment_id: this.pub_id
				}).then(res => {
					this.$Tips({
						title: '举报成功'
					}, {
						tab: 3,
						url: 1
					})
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	.question-page {
		width: 100%;
		min-height: 100vh;
		background-color: #f7f8fa;
		position: relative;

		.contentBox {
			min-height: 80vh;
			padding: 20rpx;
			box-shadow: 0rpx 4rpx 32rpx 0rpx #FFF0FD;
			border-radius: 32rpx;

			.submit-type {
				font-weight: bold;
				font-size: 36rpx;
				color: #323334;
			}

			.content-box,
			.image-box {
				margin-top: 20rpx;

				.title {
					font-size: 28rpx;
					margin: 20rpx 0 20rpx;
				}

				::v-deep .u-textarea {
					background-color: #EFEFEF;
				}
			}

			.input-item {
				padding: 10rpx 0;

				.item-left {
					font-size: 28rpx;
					color: #606060;
					margin-bottom: 20rpx;
				}

				.item-right {
					height: 88rpx;
					line-height: 88rpx;
					background: #EFEFEF;
					border-radius: 16rpx;
					flex: 1;
				}
			}

			.reason-list {
				display: flex;
				flex-wrap: wrap;

				.reason-item {
					padding: 10rpx 20rpx;
					margin: 0 10rpx 10rpx 0;
					border: 1rpx solid #E6E6E6;
					border-radius: 44rpx;
					font-size: 28rpx;
					color: #606060;
				}

				.active {
					border: 1rpx solid #0095f8;
					color: #0095f8;
				}
			}

			.button-group {
				.button1 {
					margin: 160rpx auto 0;
					width: 628rpx;
					height: 88rpx;
					font-weight: bold;
					font-size: 30rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 88rpx;
					background: #0095f8;
					box-shadow: 0px 2px 4px 0px rgba(0, 149, 248, 0.5);
					border-radius: 44rpx;
				}
			}
		}
	}
</style>